import Vue from 'vue'
import App from './App.vue'
import router from './router'

import axios from 'axios'
axios.defaults.baseURL = 'http://liangwei.tech:3000'
Vue.prototype.$axios = axios

axios.interceptors.request.use(config => {
  if(!config.headers.Authorization && localStorage.getItem('token')) {
    config.headers.Authorization = localStorage.getItem('token')
  }
  return config
})

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

Vue.filter('fixImgUrl', (oldUrl) => {
  if(oldUrl.indexOf('http') > -1) {
    return oldUrl
  } else {
    return axios.defaults.baseURL + oldUrl
  }
})

Vue.config.productionTip = false

new Vue({
  router,
  render: function(h) {return h(App)}
}).$mount('#app')
